package temp.dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import temp.model.Text;

/**
 * @author Paziy Evgeniy
 * @version 1.0
 * @since 12.03.14
 */
@Transactional
@Repository
public class HibernateTest {
    @Autowired
    private SessionFactory sessionFactory;

    public void create(Text text) {
        Session session = sessionFactory.getCurrentSession();
        session.save(text);
    }

    public Text get(int id) {
        Session session = sessionFactory.getCurrentSession();
        return (Text)session.get(Text.class, id);
    }
}
